#ifndef _CANAY2_UTIL_CORO_ERROR_H_
#define _CANAY2_UTIL_CORO_ERROR_H_

#include <string_view>
#include <stdexcept>

namespace wilson::util
{
    class coro_error : public ::std::exception
    {
    public:
        coro_error() = default;
        coro_error(::std::exception_ptr p) : ce_std_except{ p } {}
        coro_error(::std::string_view msg, int code = 0)
            : ce_msg{ msg }, ce_error_code{ 0 }
        {
        }

        virtual const char* what() const noexcept override
            { return ce_msg.data(); }

        operator int() const noexcept { return ce_error_code; }
        
    private:
        ::std::string_view ce_msg{};
        int ce_error_code{};
        ::std::exception_ptr ce_std_except;
    };
}

#endif
